import java.util.*;
public class StudentTest {
    public static void main(String args[ ]) {
        List<Student> list = new LinkedList<Student>();
        list.add(new Student("20165314","陈由章",'m',20, 90,90,90));
        list.add(new Student("20165315","阎含",'f',17,80,80,80));
        list.add(new Student("20165316","孙勖哲",'m',20,70,70,70));
        list.add(new Student("20165317","宁心宇",'m',20,60,60,60));
        list.add(new Student("20165318","孙晓暄",'f',17,95,95,95));
        Iterator<Student> iter=list.iterator();
        System.out.println("排序前,链表中的数据");
        while(iter.hasNext()){
            Student stu=iter.next();
            System.out.println(stu.getId()+ "姓名"+stu.getName());
        }
        Collections.sort(list);
        System.out.println("排序后,链表中的数据");
        iter=list.iterator();
        while(iter.hasNext()){
            Student stu=iter.next();
            System.out.println(stu.getId()+ "姓名:"+stu.getName());
        }
        Collections.sort(list, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return -(o2.getId().compareTo(o1.getId()));
            }
        });
        System.out.println("排序后,链表中的数据");
        iter=list.iterator();
        while(iter.hasNext()){
            Student stu=iter.next();
            System.out.println(stu.getId()+ "姓名:"+stu.getName());
        }
        Collections.sort(list, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return  (int)-((o2.getTotalScore()-o1.getTotalScore()));
            }
        });
        System.out.println("排序后,链表中的数据");
        iter=list.iterator();
        while(iter.hasNext()){
            Student stu=iter.next();
            System.out.println(stu.getId()+ "姓名:"+stu.getName());
        }
        /*Student zhaoLin = new Student("zhao xiao lin",178);
        int index = Collections.binarySearch(list,zhaoLin,null);
        if(index>=0) {
            System.out.println(zhaoLin.name+"和链表中"+list.get(index).name+"身高相同");
        }*/
    }
}
